<?php
/**
 * 
 * 
 * @package WKernel
 *
 */
class WK_Data_Util {
	protected function castToObject(&$value) {
		if(is_array($value))
			if($this->isNumberedArray($value))
				return new WK_Data_Collection($value);
			else
				return new WK_Data_Map($value);
		else 
			return new WK_Data_Value($value);
	}
	
	protected function isNumberedArray(&$value) {
		if(is_array($value))
			return is_integer(key($value));
		else 
			return false;
	}
	
	protected function &dataToSimpleType($value){
		if ($value instanceof WK_Data_Map || $value instanceof  WK_Data_Collection)
			return $value->__toArray();
		elseif ($value instanceof WK_Data_Value)
			return $value->v;
		else
			return $value;
	}
}